package com.example.myapplication

import factorialByTailrec
import org.junit.Test
import sumByFold
import sumByReduce
import java.math.BigInteger

/**
 *Create by Fanketly on 2022/9/5
 *Gitee:https://gitee.com/fanketly
 *desc:
 */
class FunTest {
    val intArray = intArrayOf(1, 2, 3, 2321, 4)

    @Test
    fun sum() {
        println(sumByFold(intArray))
        println(sumByReduce(intArray))
    }

    @Test
    fun wrap300Width() {
        val currentTimeMillis = System.currentTimeMillis()
//        println(factorialByTailrec(50))
        println(factorial(50))
        val currentTimeMillis1 = System.currentTimeMillis()
        println(currentTimeMillis1 - currentTimeMillis)
    }


}

fun factorial(int: Int): BigInteger {
    var integer = BigInteger.ONE
    for (i in 2L..int) {
        integer *= BigInteger.valueOf(i)
    }
    return integer
}